如何在 C# 中使用 Tesseract OCR 置信度值 | IronOCR

How to Get Read Confidence

This article was translated from English: Does it need improvement?
Translated
View the article in English

在 OCR(光學字符識別)中,讀取信心是指 OCR 系統對其在影像或文件中識別出的文本準確性的確定或可靠程度。 這是對 OCR 系統對識別文本正確性信心度的測量。

高信心分數表示對識別準確性確定程度很高,而低信心分數則表明識別可能不太可靠。

快速入門:一行代碼獲取 OCR 讀取信心

使用 IronTesseract 的 Read 方法搭配影像文件路徑,然後訪問返回的 OcrResult 中的 Confidence 屬性,以查看 IronOCR 對其文本識別的確定程度。 這是一種簡單且可靠的方式來開始評估 OCR 輸出準確性。

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. Copy and run this code snippet.

    double confidence = new IronOcr.IronTesseract().Read("input.png").Confidence;
  3. Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer
class="hsg-featured-snippet">

最小工作流程(5 個步驟)

  1. 下載 C# 庫以訪問讀取信心
  2. 準備目標影像和 PDF 文件
  3. 訪問 OCR 結果的 Confidence 屬性
  4. 檢索頁面、段落、行、單詞和字符的信心度
  5. 檢查 Choices 屬性以獲取替代單詞選擇


獲取讀取信心範例

在對輸入影像進行 OCR 後,文本的信心水平儲存在 Confidence 屬性中。 使用 'using' 語句自動釋放使用後的物件。 使用 OcrImageInputOcrPdfInput 類分別新增影像和 PDF 等文件。 Read 方法將返回一個 OcrResult 對象,允許訪問 Confidence 屬性。

:path=/static-assets/ocr/content-code-examples/how-to/tesseract-result-confidence-get-confidence.cs
using IronOcr;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("sample.tiff");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);

// Get confidence level
double confidence = ocrResult.Confidence;
Imports IronOcr

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Add image
Private imageInput = New OcrImageInput("sample.tiff")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)

' Get confidence level
Private confidence As Double = ocrResult.Confidence
$vbLabelText   $csharpLabel

在不同層次獲取讀取信心

不僅可以檢索整個文件的置信水平,還可以訪問每一頁、每個段落、行、單詞和字符的信心水平。 此外,還可以獲取表示一組或多個緊鄰段落集合的塊的信心。

:path=/static-assets/ocr/content-code-examples/how-to/tesseract-result-confidence-confidence-level.cs
// Get page confidence level
double pageConfidence = ocrResult.Pages[0].Confidence;

// Get paragraph confidence level
double paragraphConfidence = ocrResult.Paragraphs[0].Confidence;

// Get line confidence level
double lineConfidence = ocrResult.Lines[0].Confidence;

// Get word confidence level
double wordConfidence = ocrResult.Words[0].Confidence;

// Get character confidence level
double characterConfidence = ocrResult.Characters[0].Confidence;

// Get block confidence level
double blockConfidence = ocrResult.Blocks[0].Confidence;
' Get page confidence level
Dim pageConfidence As Double = ocrResult.Pages(0).Confidence

' Get paragraph confidence level
Dim paragraphConfidence As Double = ocrResult.Paragraphs(0).Confidence

' Get line confidence level
Dim lineConfidence As Double = ocrResult.Lines(0).Confidence

' Get word confidence level
Dim wordConfidence As Double = ocrResult.Words(0).Confidence

' Get character confidence level
Dim characterConfidence As Double = ocrResult.Characters(0).Confidence

' Get block confidence level
Dim blockConfidence As Double = ocrResult.Blocks(0).Confidence
$vbLabelText   $csharpLabel

獲取字符選擇

除了信心水平之外,還有另一個有趣的屬性叫做 Choices。 Choices 包含一個替代單詞選擇及其統計相關性的列表。 此信息允許用戶訪問其他可能的字符。

:path=/static-assets/ocr/content-code-examples/how-to/tesseract-result-confidence-get-choices.cs
using IronOcr;
using static IronOcr.OcrResult;

// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();

// Add image
using var imageInput = new OcrImageInput("Potter.tiff");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);

// Get choices
Choice[] choices = ocrResult.Characters[0].Choices;
Imports IronOcr
Imports IronOcr.OcrResult

' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()

' Add image
Private imageInput = New OcrImageInput("Potter.tiff")
' Perform OCR
Private ocrResult As OcrResult = ocrTesseract.Read(imageInput)

' Get choices
Private choices() As Choice = ocrResult.Characters(0).Choices
$vbLabelText   $csharpLabel

檢索的信息

class="content-img-align-center">
class="center-image-wrapper"> Choices

常見問題解答

OCR中的讀取置信度是什麼意思?

OCR辨識中的讀取置信度是指OCR系統對辨識文字準確度的確定性或可靠性等級。高分錶示文字辨識可靠,低分則表示可能有錯誤。

我該如何使用 C# 函式庫來取得 OCR 讀取置信度?

首先從 NuGet 下載 IronOCR 庫。準備好要處理的影像或 PDF 文檔,並使用Read方法存取OcrResult物件的Confidence屬性。

如何在C#中取得識別文字的置信度?

若要取得辨識文字的置信度,請使用 IronOCR 的Read方法,該方法傳回一個OcrResult物件。此物件包含一個Confidence屬性,用於指示文字的準確度。

我可以查看文件不同部分的置信度嗎?

是的,IronOCR 可讓您檢查文件各部分的置信度,包括頁面、段落、行、單字和字元。這可以對 OCR 過程的準確性進行詳細評估。

OCR中的字元選擇有哪些?

OCR中的字元選擇功能提供了一系列替代詞語及其統計相關性。此功能可協助使用者了解OCR系統可能識別的其他字符,從而更深入地了解識別過程。

C# OCR 庫中如何使用 confidence 屬性?

C# OCR 庫中的Confidence屬性指示辨識文字的準確度。它提供一個數值分數,表示 OCR 系統對辨識準確度的確定程度。

是否可以在 C# OCR 庫中存取區塊級置信度?

是的,您可以使用 IronOCR 來取得區塊級置信度。一個區塊代表一組緊密相鄰的段落,您可以檢查其置信度來評估該層級的文字辨識準確率。

OCR 中的 Choices 屬性有什麼用途?

Choices功能提供備選詞語及其信賴度評分。這有助於使用者了解 OCR 系統提供的其他潛在文本解釋,從而提升對識別文本的評估。

如何在C#中實現有置信度的OCR?

使用 IronOCR 庫在 C# 中實現具有置信度等級的 OCR。設定好環境,準備好輸入文檔,然後使用Read方法取得OcrResult對象,從中可以存取Confidence屬性。

使用 C# OCR 庫評估讀取置信度時,我應該遵循哪些步驟?

要評估讀取置信度,請下載 IronOCR 庫,準備用於 OCR 處理的文檔,使用Read方法獲取OcrResult ,然後訪問Confidence屬性來評估識別文本的準確性。

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

審核人

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'name'

Filename: sections/author_component.php

Line Number: 70

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 70
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/how-to/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Howto.php
Line: 31
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

">

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'title'

Filename: sections/author_component.php

Line Number: 84

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 84
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/how-to/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Howto.php
Line: 31
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Illegal string offset 'comment'

Filename: sections/author_component.php

Line Number: 85

Backtrace:

File: /var/www/ironpdf.com/application/views/main/sections/author_component.php
Line: 85
Function: _error_handler

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 63
Function: view

File: /var/www/ironpdf.com/application/views/products/sections/three_column_docs_page_structure.php
Line: 64
Function: main_view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/views/products/how-to/index.php
Line: 2
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 88
Function: view

File: /var/www/ironpdf.com/application/libraries/Render.php
Line: 552
Function: view

File: /var/www/ironpdf.com/application/controllers/Products/Howto.php
Line: 31
Function: render_products_view

File: /var/www/ironpdf.com/index.php
Line: 292
Function: require_once